#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
int n, m; vector < pair < int, int > > ans; bool flg, f[200009], g[200009];
inline void ins(int x, int y) { if ( !f[x + y] && !g[x - y + m] ) f[x + y] = g[x - y + m] = true, ans.emplace_back(x, y); }
int main()
{
	freopen("bishop.in", "r", stdin), freopen("bishop.out", "w", stdout);
	cin.tie(nullptr) -> sync_with_stdio(false);
	cin >> n >> m, ans.reserve(n + m); if ( flg = n > m ) swap(n, m);
	For(i, 1, n) ins(i, 1);
	For(i, 1, n) ins(i, m);
	For(i, 1, m) ins(( n + 1 ) >> 1, i), ins(( n >> 1 ) + 1, i);
	cout << ans.size() << '\n';
	for ( auto _ : ans ) { if ( flg ) swap(_.first, _.second); cout << _.first << ' ' << _.second << '\n'; }
	return 0;
}